package com.ruoyi.web.controller.warning;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.warning.domain.entity.Template;
import com.ruoyi.warning.domain.query.TemplateQuery;
import com.ruoyi.warning.service.ITemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/warning/template")
@Api(tags = "告警模版", description = "用于处理告警模版相关操作的控制器")
public class TemplateController {
    @Resource
    private ITemplateService iTemplateService;

    @ApiOperation("分页")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @GetMapping(value = "/page")
    public R<TableDataInfo> page(TemplateQuery query)
    {
        return R.ok(iTemplateService.getTemplatePage(query));
    }

    @ApiOperation("列表")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @GetMapping(value = "/list")
    public R list(TemplateQuery query)
    {
        return R.ok(iTemplateService.getTemplateList(query));
    }

    @ApiOperation("详情")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @GetMapping(value = "/details/{id}")
    public R getDetails(@PathVariable Long id)
    {
        return R.ok(iTemplateService.getDetails(id));
    }

    @ApiOperation("新增")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @PutMapping(value = "/save")
    public R saveTemplate(@RequestBody Template template)
    {
        return R.ok(iTemplateService.saveTemplate(template));
    }

    @ApiOperation("删除")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @PostMapping (value = "/delete")
    public R deleteTemplate(@RequestBody List<String> ids)
    {
        return R.ok(iTemplateService.deleteTemplate(ids));
    }

    @ApiOperation("修改")
    //@PreAuthorize("@ss.hasPermi('system:config:export')")
    @PutMapping (value = "/update")
    public R updateTemplate(@RequestBody Template template)
    {
        return R.ok(iTemplateService.updateTemplate(template));
    }


}
